package movie.ticketing.system.view;



import movie.ticketing.system.dao.UserDAO;
import movie.ticketing.system.model.User;

import javax.swing.*;

/**
 * 管理员登录
 */
public class Login {
    public void login() {
        JFrame frameLogin = new JFrame("登录");
        frameLogin.setSize(400, 250);
        frameLogin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frameLogin.setLocationRelativeTo(null);// 居中显示
        JPanel panelLogin = new JPanel();
        frameLogin.add(panelLogin);
        panelLogin.setLayout(null);// 设置布局为空布局

        JLabel userLabel = new JLabel("用户名：");
        userLabel.setBounds(20, 20, 80, 30);
        panelLogin.add(userLabel);

        JTextField userField = new JTextField();
        userField.setBounds(100, 20, 200, 30);
        panelLogin.add(userField);

        JLabel passwordLabel = new JLabel("密码：");
        passwordLabel.setBounds(20, 60, 80, 30);
        panelLogin.add(passwordLabel);

        JPasswordField passwordField = new JPasswordField();
        passwordField.setBounds(100, 60, 200, 30);
        panelLogin.add(passwordField);

        JComboBox<String> comboBox = new JComboBox<>();
        comboBox.addItem("用户");
        comboBox.addItem("管理员");
        comboBox.setBounds(100, 100, 200, 30);
        panelLogin.add(comboBox);

        JButton loginButton = new JButton("登录");
        loginButton.setBounds(100, 150, 100, 30);
        panelLogin.add(loginButton);


        JButton registerButton = new JButton("注册");
        registerButton.setBounds(200, 150, 100, 30);
        panelLogin.add(registerButton);
        frameLogin.setVisible(true);

        loginButton.addActionListener(e -> { // TODO 登录按钮


        });
        registerButton.addActionListener(e -> {
            frameLogin.dispose();
            new Enroll().enroll();
        });

    }
}
